const express =require('express');
const {resolve} = require('path');
const pageRouter = require('./routes/pageRouter')
const apiRouter = require('./routes/apiRouter')
const loginRouter = require('./routes/loginRouter');

const ejs = require('ejs');
const session = require('express-session');
const app = express();

app.engine('html',ejs.renderFile);
app.use(express.urlencoded({extended:false}))
app.use(express.static(resolve(__dirname,'./public')))
app.use(session({
    name:"s_id",
    secret:"CD0417",
    saveUninitialized:true,
    resave:true,
    cookie:{
        httpOnly:true,
        maxAge:1000*60*60
    }
}))



app.use(pageRouter);
app.use(apiRouter);
app.use(loginRouter);

app.listen(80,()=>{
    console.log("启动成功");
})